package main.java.com.manger.service.Impl;

import com.manger.constant.Constant;
import com.manger.dao.StudentMapper;
import com.manger.dto.Login;
import com.manger.entity.Student;
import com.manger.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;

/**
 * Created by LCJ on 2017/6/14.
 */
@Service
public class LoginServiceImpl implements LoginService {

    @Autowired
    private StudentMapper studentMapper;

    @Override
    public Object login(Login login, HttpSession session) {
        Student student = studentMapper.login(login);
        if (student == null || student.equals("")) {
            return Constant.LOGIN_FAILURE;
        }
        session.setAttribute("no", login);
        return student;
    }
}
